import random
from PIL import Image
import os
import sys
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt

import pylab
base_dir2 = os.getcwd()
base_dir = os.getcwd()+r"\1.jpg"
# str2 = ''
# head = random.randint(0xB0, 0xCF)
# body = random.randint(0xA1, 0xFe)
# val = f'{head:x} {body:x}'
# str = bytes.fromhex(val).decode('gb2312')
# print(str)
#
# print([1,2,3]+['c',5,'8'])
# print(124 % 10)
# def get_num(self, num):
#     first = str(random.randint(1, 9))
#     res = first + "".join([str(random.randint(0, 9)) for i in range(len(num) - 1)])
#     print(res)
#     return res
#
# print("5"+"".join([str(random.randint(0, 9)) for i in range(5)]))
def check_gray_image(img_path):
    img=Image.open(img_path)
    img=img.convert('L')
    # img.name = '44.jpg'
    img.save('44.jpg')
    layers=img.tell
    #彩色通道没有layers方法 ，会报错
    # layers=img.layers
    if(layers==1):
        print(1)
        return True
    else:
        print(0)
        return False


def gray(path):
    j = plt.imread(path)
    # plt.imshow(j)

    j_max = j.max(axis=-1)
    plt.imshow(j_max, cmap="gray")
    pylab.show()
#
# print(base_dir)
# check_gray_image(base_dir)
# gray(base_dir)
# num = [4,5,7,1,5,6]
# print(sorted(num))
# -------
class Player1:
    def __init__(self,name,atk):
        self.name = name
        self.atk = atk

    def attack(self):
        e = Enemy1(100)
        e.denmage(self.atk)


class Enemy1:
    def __init__(self,hp,name="小兵"):
        self.hp = hp
        self.name = name
    def denmage(self,value):
        self.hp -= value
        if value<= 0:
            return 'death'

# --------------
class Player2:
    def __init__(self, name, atk):
        self.name = name
        self.atk = atk
        self.e = Enemy2(100)

    def attack(self):
        self.e.denmage(self.atk)


class Enemy2:
    def __init__(self, hp, name="小兵"):
        self.hp = hp
        self.name = name

    def denmage(self, value):
        self.hp -= value
        if value <= 0:
            return 'death'

#----------
class Player3:
    def __init__(self, name, atk):
        self.name = name
        self.atk = atk


    def attack(self,target):
        target.denmage(self.atk)


class Enemy3:
    def __init__(self, hp, name="小兵"):
        self.hp = hp
        self.name = name

    def denmage(self, value):
        self.hp -= value
        if value <= 0:
            return 'death'




